/**
 * Copyright (c) 2008 - TheNittyGritty - Thomas Brekelmans
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package nl.thenittygritty.list.sorter
{
	import nl.thenittygritty.specification.ISpecification;	

	/**
	 * Criterion is a helper data class used in nl.thenittygritty.list.sorter.Sorter;
	 */
	final public class Criterion
	{
		private var specification:ISpecification;
		private var sortingAlgorithm:Function;
		private var sortingOptions:Number;
		
		/**
		 * Creates a new Criterion.
		 * 
		 * @param specification The specification which creates a sublists of the list which is sorted by the sorter to which this criterion is added.
		 * @param sortingAlgorithm An array sorting algorithm method which sorts the created sublists.
		 * @param sortingOptions An array sorting option id such as Array.NUMERIC which is used instead of the sortingAlgorithm. See the array documentation for more info.
		 */
		public function Criterion(specification:ISpecification, sortingAlgorithm:Function = null, sortingOptions:Number = 0):void
		{
			this.specification = specification;
			
			this.sortingAlgorithm = sortingAlgorithm;
			this.sortingOptions = sortingOptions;
		}

		/**
		 * Returns the stored specification used for this criterion.
		 */
		public function getSpecification():ISpecification
		{
			return this.specification;
		}

		/**
		 * Returns the stored sorting algorithm used for this criterion.
		 */
		public function getSortingAlgorithm():Function
		{
			return this.sortingAlgorithm;
		}

		/**
		 * Returns the stored sorting options used for this criterion.
		 */
		public function getSortingOptions():Number
		{
			return this.sortingOptions;
		}

		/**
		 * Returns the name of the class in a String.
		 */
		public function toString():String
		{
			return "Criterion";
		}
	}
}